# 回溯算法 全排列
def permute(nums):
    used=[False]*len(nums) #用来判断数组传入情况
    result=[]
    path=[]
    def backtracking(nums,used):
        # 终止条件
        if len(nums)==len(path):
            result.append(path.copy())
            return
        for i in range(len(nums)):
            if used[i]==True:
                continue
            used[i]=True
            path.append(nums[i])
            backtracking(nums,used)
            used[i]=False
            path.pop()
    backtracking(nums,used)
    return result
lt=permute([1,2,3])
print(lt)
